<?php

include_once("class_lib.php");

$ctrl = new controller();

$tags = $ctrl->getTags($_GET["tag"]);

$tagIsSet = (isset($_GET["tag"]) && !empty($_GET["tag"]))? true : false;
$taggableIsSet = (isset($_GET["taggable"]) && !empty($_GET["taggable"]))? true : false;

if ($tagIsSet)
{
	$href = "?";
	
	$tagLevels = split("/", stripslashes($_GET["tag"]));
	array_pop($tagLevels);

	$hasParentTag = (count($tagLevels) > 0)? true : false;

	if ($hasParentTag)
	{
		$href .= "tag=" . join("/", $tagLevels);
	}
	
	if ($taggableIsSet)
	{	
		if ($hasParentTag)
		{
			$href .= "&";
		}
		
		$href .= "taggable=" . $_GET["taggable"];
	}

	print "<p><a href=\"" . $href . "\"><< Up</a></p>";

}

foreach($tags as $tag)
{
	if ($taggableIsSet)
	{
		print "<li><a href=\"?tag=" . $tag->getName() . "&taggable=" . $_GET["taggable"] . "\">" . $tag->getName() . "</a> <a class=\"remove\" href=\"remove/" . $tag->getName() . "\">(remove)</a></li>";
	}
	else
	{
		print "<li><a href=\"?tag=" . $tag->getName() . "\">" . $tag->getName() . "</a> <a class=\"remove\" href=\"remove/" . $tag->getName() . "\">(remove)</a></li>";
	}
}




?>
